﻿Public Class OptionsDialog

    Private v As New SpeechLib.SpVoice

#Region "Loaded"

    Private Sub OptionsDialog_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) _
    Handles Me.Loaded
        StartUpComboBox.SelectedIndex = My.Settings.Options_StartupMode
        If My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeBlack Then
            ComboBox2.SelectedIndex = 0
        ElseIf My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeBlue Then
            ComboBox2.SelectedIndex = 1
        ElseIf My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeSilver Then
            ComboBox2.SelectedIndex = 2
        ElseIf My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.Windows7 Then
            ComboBox2.SelectedIndex = 3
        End If
        ComboBox1.SelectedIndex = My.Settings.Options_Tabs_SizeMode
        SpellCheckBox.IsChecked = My.Settings.Options_SpellCheck
        If My.Settings.Options_IsGlassOn Then
            EnableGlassCheckBox.IsChecked = True
        End If
        If MS.WindowsAPICodePack.Internal.CoreHelpers.RunningOnVista Or _
        MS.WindowsAPICodePack.Internal.CoreHelpers.RunningOnWin7 Then
            If My.Settings.Options_IsGlassOn Then
                GlassHelper.ExtendGlassFrame(Me, New Thickness(-1, -1, -1, -1))
            End If
        End If
        If My.Settings.Options_Language = "en-US" Then
            USRadioButton.IsChecked = True
        ElseIf My.Settings.Options_Language = "es-ES" Then
            ESRadioButton.IsChecked = True
        End If
        Dim Token As SpeechLib.ISpeechObjectToken
        For Each Token In v.GetVoices
            TTSComboBox.Items.Add((Token.GetDescription()))
        Next Token
        TTSComboBox.SelectedIndex = My.Settings.Options_TTSV
        v = Nothing
        CloseButtonComboBox.SelectedIndex = My.Settings.Options_Tabs_CloseButtonMode
    End Sub

#End Region

#Region "OKButton"

    Private Sub OKButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles OKButton.Click
        My.Settings.Options_StartupMode = StartUpComboBox.SelectedIndex
        If SpellCheckBox.IsChecked Then
            My.Settings.Options_SpellCheck = True
        Else
            My.Settings.Options_SpellCheck = False
        End If
        If ComboBox2.SelectedIndex = 0 Then
            My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeBlack
        ElseIf ComboBox2.SelectedIndex = 1 Then
            My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeBlue
        ElseIf ComboBox2.SelectedIndex = 2 Then
            My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.OfficeSilver
        ElseIf ComboBox2.SelectedIndex = 3 Then
            My.Settings.Options_Theme = Odyssey.Controls.Classes.SkinId.Windows7
        End If
        If EnableGlassCheckBox.IsChecked Then
            My.Settings.Options_IsGlassOn = True
        Else
            My.Settings.Options_IsGlassOn = False
        End If
        If USRadioButton.IsChecked Then
            My.Settings.Options_Language = "en-US"
        ElseIf ESRadioButton.IsChecked Then
            My.Settings.Options_Language = "es-ES"
        End If
        My.Settings.Options_TTSV = TTSComboBox.SelectedIndex
        My.Settings.Options_Tabs_CloseButtonMode = CloseButtonComboBox.SelectedIndex
        Close()
    End Sub
#End Region

    Private Sub CancelButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) _
    Handles CancelButton.Click
        Close()
    End Sub

    Private Sub ClearRecentButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) _
    Handles ClearRecentButton.Click
        My.Settings.Options_RecentFiles.Clear()
    End Sub
End Class